import {container} from "./container.js";
import {storeToRefs} from "pinia";
import  {usePixiStore}  from '@/store/pixi'
import {textContainer} from "./textContainer.js";
import {spriteContainer} from "./spriteContainer.js";
import {dashContainer} from "./dashContainer.js";
import {bgContainer} from "./bgContainer.js";
import {pathContainer} from "./pathContainer.js";


export function addAllContainer(){
    // 最先加入的在最底下 默认
    container.addChild(bgContainer)
    container.addChild(textContainer)
    container.addChild(spriteContainer)
    container.addChild(dashContainer)
    container.addChild(pathContainer)
}

export function clearAllContainer(){
    // 清除各个container的dashs 防止内存泄露
    bgContainer.removeChildren(0,bgContainer.children.length);
    dashContainer.removeChildren(0,dashContainer.children.length);

    let store = usePixiStore()
    let { canvas2Dcontainer, currentWidth, currentHeight} =  storeToRefs(store)
    store.clearCanvas2Dcontainer()

    textContainer.removeChildren(0,textContainer.children.length);
    spriteContainer.removeChildren(0,spriteContainer.children.length);
    pathContainer.removeChildren(0,pathContainer.children.length);

    container.removeChildren(0,container.children.length);

    container.x = currentWidth.value/2;
    container.y = currentHeight.value/2;
}
